package com.xy.wrapper;

import com.xy.entity.CertificateApplyEntity;
import com.xy.entity.CertificateTypeEntity;
import com.xy.excel.PersonnelExcel;
import com.xy.excel.VehicleExcel;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictBizCache;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @BelongsPackage: com.xy.wrapper
 * @Author: WK
 * @CreateTime: 2023-07-19
 * @Description:
 * @Version: 1.0
 */
public class ExcelWapper {

	private static final Map<Integer ,String> STATUS_MAP = new HashMap<>();

	static {
		//审核状态：0-未审核，1审核通过，2审核驳回,3-审核中
		STATUS_MAP.put(0, "待审核");
		STATUS_MAP.put(1, "审核通过");
		STATUS_MAP.put(2, "已驳回");
		STATUS_MAP.put(3, "审核中");
	}
	public static ExcelWapper build() {
		return new ExcelWapper();
	}

	private final static String NATIONALITY_CODE = "nationality";

	public VehicleExcel toVe(CertificateApplyEntity entity) {
		if (Func.isNull(entity)) {
			return new VehicleExcel();
		}
		VehicleExcel excel = Func.copy(entity, VehicleExcel.class);
		excel.setType(entity.getTypeName());
		String desc = STATUS_MAP.get(entity.getBizStatus());
		if(Func.isNotEmpty(desc)){
			excel.setBizCode(desc);
		}
		return excel;
	}

	public PersonnelExcel toPe(CertificateApplyEntity entity) {
		if (Func.isNull(entity)) {
			return new PersonnelExcel();
		}
		PersonnelExcel excel = Func.copy(entity, PersonnelExcel.class);
//		String value = DictBizCache.getValue(NATIONALITY_CODE, entity.getNationality());
//		if (Func.isNotEmpty(value)) {
//			excel.setNationality(value);
//		}
		String desc = STATUS_MAP.get(entity.getBizStatus());
		if(Func.isNotEmpty(desc)){
			excel.setBizCode(desc);
		}

		excel.setType(entity.getTypeName());
		return excel;
	}

	public List<VehicleExcel> listVe(List<CertificateApplyEntity> list) {
		return list.stream().map(this::toVe).collect(Collectors.toList());
	}

	public List<PersonnelExcel> listPe(List<CertificateApplyEntity> list) {
		return list.stream().map(this::toPe).collect(Collectors.toList());
	}
}
